package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: TaskStagesServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-18
 * @Version: 1.0
 * Table: pear_task_stages
 * Comment:
 * 任务列表表
 */
@Service
public class TaskStagesServiceImpl extends TaskStagesServiceCustomImpl implements TaskStagesService {

    static {
        beanClassNameMap.put("task_stages", "taskStagesServiceImpl");
        listMethodNameMap.put("task_stages", "listTaskStages");
        listMethodParameterClassNameMap.put("task_stages", "TaskStagesQueryRequest");
        updateMethodNameMap.put("task_stages", "updateTaskStages");
        updateMethodParameterClassNameMap.put("task_stages", "TaskStagesUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addTaskStages(TaskStagesAddRequest request) throws Exception {
        super.fixRequest("task_stages", "add", request);
        return super.addTaskStages(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateTaskStages(TaskStagesUpdateRequest request) throws Exception {
        TaskStages record = null;
        record = taskStagesMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("task_stages", "update", request, record);
        return super.updateTaskStages(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteTaskStages(TaskStagesDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<TaskStages> list = null;
            TaskStagesExample example = new TaskStagesExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = taskStagesMapper.selectByExample(example);
            fixRequest("task_stages", "delete", request, list);
        } else {
            fixRequest("task_stages", "delete", request);
        }
        return super.deleteTaskStages(request);
    }

    @Override
    public TaskStagesQueryResponse queryTaskStages(TaskStagesQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        TaskStagesQueryResponse result = super.queryTaskStages(request);
        checkResult("task_stages", "query", request, result);
        return result;
    }

    @Override
    public List<TaskStagesQueryResponse> listTaskStages(TaskStagesQueryRequest request) throws Exception {
        List<TaskStagesQueryResponse> list = super.listTaskStages(request);
        checkResult("task_stages", "list", request, list);
        return list;
    }

    @Override
    public Integer countTaskStages(TaskStagesQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("task_stages", "count", request);
        return super.countTaskStages(request);
    }

    @Override
    public BaseStatResponse statTaskStages(TaskStagesQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("task_stages", "stat", request);
        return super.statTaskStages(request);
    }

}
